package com.fanw.easyExport.demo;

import com.fanw.easyExport.core.data.DataFetcher;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 演示用数据获取器
 */
public class DemoDataFetcher implements DataFetcher {

    @Override
    public List<Map<String, Object>> fetchData() {
        List<Map<String, Object>> data = new ArrayList<>();

        // 添加示例数据
        data.add(createRow(1, "Alice", "alice@example.com", 28));
        data.add(createRow(2, "Bob", "bob@example.com", 32));
        data.add(createRow(3, "Charlie", "charlie@example.com", null)); // 测试空值

        return data;
    }

    private Map<String, Object> createRow(int id, String name, String email, Integer age) {
        Map<String, Object> row = new HashMap<>();
        row.put("id", id);
        row.put("name", name);
        row.put("email", email);
        row.put("age", age);
        return row;
    }
}
